<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="../../../static/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../../static/js/jquery.js"></script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li>仓库管理</li>
        <li>入库管理</li>
        <li>采购单详情</li>
    </ul>
</div>
<div class="formbody">
    <div class="formtitle"><span>采购单信息</span></div>
    <ul class="forminfo">
        <li>
            <label>采单编号</label>
            <cite id="purchaseId">CG201711180001</cite>
        </li>
        <li>
            <label>采购时间</label>
            <cite id="purchaseTime">2017-11-18 15:36:10</cite>
        </li>
        <li>
            <label>总金额</label>
            <cite id="totalMoney">￥9,876,582</cite>
        </li>
        <li>
            <label>操作人</label>
            <cite id="creatName">关羽</cite>
        </li>
        <li>
            <label>审核状态</label>
            <cite id="checkStatus">已审核通过</cite>
        </li>
        <li>
            <label>审核意见</label>
            <cite id="checkOpinion">做的很详细，同意通过</cite>
        </li>
        <li>
            <label>审核人</label>
            <cite id="checkName">曹操</cite>
        </li>
        <li>
            <label>审核时间</label>
            <cite id="checkTime">2017-01-30 12:05:05</cite>
        </li>
        <li>
            <label>入货仓库</label>
            <cite id="cname">南京21号仓库</cite>
        </li>
        <li>
            <label>入库时间</label>
            <cite id="rkDate">2013-09-09 15:05:05</cite>
        </li>
        <li>
            <label>入库人</label>
            <cite id="rkName">朱元璋</cite>
        </li>
        <li>
            <label>入库状态</label>
            <cite id="cgState">已入库</cite>
        </li>
    </ul>
    <table class="tablelist">
        <thead>
        <tr>
            <th>序号</th>
            <th>品牌</th>
            <th>类型</th>
            <th>型号</th>
            <th>厂商</th>
            <th>数量</th>
            <th>单位</th>
            <th>单价</th>
            <th>金额</th>
        </tr>
        </thead>
        <tbody id="Details">

        </tbody>
    </table>
    <div style="margin-top:20px; margin-left:20px;">
        <input name="" type="button" class="btn" value="返回" onclick="window.history.go(-1);"/>
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');

    $(function () {
        var purchaseid = getParameter("purchaseid");
        // alert(purchaseid)
        queryPurchaseidView(purchaseid);
    })

    function queryPurchaseidView(purchaseid) {
        $.ajax({
            url: "/purchase/queryPurchaseDetails",
            method: "post",
            dataType: "json",
            data: {purchaseId: purchaseid},
            success: function (pb) {
                console.log(pb);
                $('#purchaseId').html(pb.data.purchaseId);
                $('#purchaseTime').html(pb.data.purchaseTime);
                $('#totalMoney').html(pb.data.totalMoney);
                $('#creatName').html(pb.data.creatName);
                switch (pb.data.checkStatus) {
                    case 1:
                        $('#checkStatus').html("未审核");
                        break;
                    case 2:
                        $('#checkStatus').html("审核中");
                        break;
                    case 3:
                        $('#checkStatus').html("审核通过");
                        break;
                    case 4:
                        $('#checkStatus').html("审核未通过");
                        break;
                }
                $('#checkName').html(pb.data.checkName);
                $('#checkTime').html(pb.data.checkTime);
                $('#checkOpinion').html(pb.data.checkOpinion);

                let cnameMSG='<cite id="cname"><a href="../../storage/storage/storageView?id=' + pb.data.warehuoseId  +'" ' +
                    'title="点击查看仓库详细信息" class="tablelink">'+pb.data.cname+'</a></cite>';

                $('#cname').html(cnameMSG);

                $('#rkDate').html(pb.data.rkDate);
                $('#rkName').html(pb.data.rkName);
                if (pb.data.cgState == 2)
                    $('#cgState').html("已入库");//
                else {
                    $('#cgState').html("未入库");
                }

                var details = pb.data.purchaseDatails;
                details.forEach(function (item,index) {
                    let detail =
                        '<tr>' +
                        ' <td>'+(index+1)+'</td>' +
                        ' <td>'+item.brand+'</td>' +
                        ' <td>'+item.type+'</td>' +
                        ' <td>'+item.model+'</td>' +
                        ' <td>'+item.firm+'</td>' +
                        ' <td>'+item.count+'</td>' +
                        ' <td>'+item.unit+'</td>' +
                        ' <td>'+item.purchasePrice+'</td>' +
                        ' <td>'+item.totalMoney+'</td>' +
                        ' </tr>';
                    $('#Details').append(detail);
                })


                // $('#cname').val(pb.data.cname);
                // $('#cname').val(pb.data.cname);
            },
            error: function () {
                alert("查询采购单详情失败！")

            }
        })
    }

    function getParameter(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = location.search.substr(1).match(reg);
        if (r != null) {
            return (r[2]);
        }
        return null;
    }
</script>
</body>
</html>
